<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0" />
    <title>广告图片详情</title>
    <#include "/view/admin/head.html"/>

    <style type="text/css">
        .list-path{
            height: 50px;
            line-height: 50px;
            background-color: #9acfea;

        }
        .table-class{
            width:80%;
            text-align: center;
            border:1px solid #afd9ee;
            margin:0 auto;
            margin-top: 50px;
        }
        table th{
            width:20%;
            background-color: #d9edf7;
            text-align: right;
        }
        table td{
            width:20%;
            text-align: left;
        }
        .go-back{
            float:right;
            margin-right: 30px;

        }
    </style>

<script type="text/javascript">
function firstFileImg() {
		//input
		var docObj = document.getElementById("firstFile");
		//img
		var imgObjPreview = document.getElementById("firstImg");
		//div
		var divs = document.getElementById("localImag");
		if (docObj.files && docObj.files[0]) {
			//火狐下，直接设img属性
			imgObjPreview.style.width = '242px';
			imgObjPreview.style.height = '170px';
			//imgObjPreview.src = docObj.files[0].getAsDataURL();
			//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
			imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
		} else {
			//IE下，使用滤镜
			docObj.select();
			var imgSrc = document.selection.createRange().text;
			var localImagId = document.getElementById("localImag");
			//必须设置初始大小
			localImagId.style.width = "242px";
			localImagId.style.height = "170px";
			//图片异常的捕捉，防止用户修改后缀来伪造图片
			try {
				localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
				localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
			} catch(e) {
				alert("您上传的图片格式不正确，请重新选择!");
				return false;
			}
			
			imgObjPreview.style.display = 'none';
			
			document.selection.empty();
		}
		return true;
	}  

function secondFileImg() {
	//input
	var docObj = document.getElementById("secondFile");
	//img
	var imgObjPreview = document.getElementById("secondImg");
	//div
	var divs = document.getElementById("localImag");
	if (docObj.files && docObj.files[0]) {
		//火狐下，直接设img属性
		imgObjPreview.style.width = '242px';
		imgObjPreview.style.height = '170px';
		//imgObjPreview.src = docObj.files[0].getAsDataURL();
		//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
		imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
	} else {
		//IE下，使用滤镜
		docObj.select();
		var imgSrc = document.selection.createRange().text;
		var localImagId = document.getElementById("localImag");
		//必须设置初始大小
		localImagId.style.width = "242px";
		localImagId.style.height = "170px";
		//图片异常的捕捉，防止用户修改后缀来伪造图片
		try {
			localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
			localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
		} catch(e) {
			alert("您上传的图片格式不正确，请重新选择!");
			return false;
		}
		
		imgObjPreview.style.display = 'none';
		
		document.selection.empty();
	}
	return true;
}  

function thirdFileImg() {
	//input
	var docObj = document.getElementById("thirdFile");
	//img
	var imgObjPreview = document.getElementById("thirdImg");
	//div
	var divs = document.getElementById("localImag");
	if (docObj.files && docObj.files[0]) {
		//火狐下，直接设img属性
		imgObjPreview.style.width = '242px';
		imgObjPreview.style.height = '170px';
		//imgObjPreview.src = docObj.files[0].getAsDataURL();
		//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
		imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
	} else {
		//IE下，使用滤镜
		docObj.select();
		var imgSrc = document.selection.createRange().text;
		var localImagId = document.getElementById("localImag");
		//必须设置初始大小
		localImagId.style.width = "242px";
		localImagId.style.height = "170px";
		//图片异常的捕捉，防止用户修改后缀来伪造图片
		try {
			localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
			localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
		} catch(e) {
			alert("您上传的图片格式不正确，请重新选择!");
			return false;
		}
		
		imgObjPreview.style.display = 'none';
		
		document.selection.empty();
	}
	return true;
}  


</script>    
    
</head>
<body>

<div class="list-path" > <span style="margin-left: 50px;"><span class="glyphicon glyphicon-home"></span> 广告图片编辑</span></div>
    <div style="float:right;margin-right: 40px;"><a class="btn btn-info" href="${base}/advertisementimg2/czjadvertisementimg2List.do">返回上一级</a></div>
</div>


<div class="table-class">       
      <#if  message?? &&  message =="1" >
        <div class="alert alert-error" style="background-color: write;color: green;">           
           <font size="5"><strong>发布成功</strong></font>
        </div>
     </#if>
      <#if  message?? &&  message =="0" >
        <div class="alert alert-error" style="background-color: write;color: red;">           
           <font size="5"><strong>取消发布</strong></font>
        </div>
     </#if>
      <#if  message?? &&  message =="2" >
        <div class="alert alert-error" style="background-color: write;color: green;">           
           <font size="5"><strong>保存成功</strong></font>
        </div>
     </#if>     
      
    <table class="table table-bordered">
        <thead>

        </thead>
        <tbody>
          <form  action="${base}/advertisementimg2/czjadvertisementimg2Save.do?advertisementId=${czjadvertisementimg2.advertisementId!}" method="post" enctype="multipart/form-data"   id="myform" >
               <tr>
                <th>是否发布：</th>
                <td>
                   <#if  czjadvertisementimg2.ext1?? && czjadvertisementimg2.ext1 =="1">
                   <span class="label label-success">是</span>
                   <#else>
                   <span class="label label-default">否</span>
                   </#if>                                                 
                </td>
                <th>图片顺序：</th>
                <td> 
                  <input id="imgOrder" name="imgOrder" value="${czjadvertisementimg2.imgOrder!}" >
                </td>
              </tr>        
             <tr>
                <th>图片跳转地址：</th>
                <td><!-- <input type="text" name="imgUrl" value="${czjadvertisementimg2.imgUrl!}"> -->
                
                 <textarea  type="text" name="imgUrl"  rows="3"  cols="50">${czjadvertisementimg2.imgUrl!}</textarea>
                
                </td>
                <th>备注：</th>
                <td><input type="text" name="remark"value="${czjadvertisementimg2.remark!}">   </td>
              </tr>
              <tr>
                <th>上传广告图片(750x250)：</th>
                <td><input type="file" name="first" id="firstFile" onchange="firstFileImg();">                  
                <input  type="hidden" name="imgFirst"  value="${czjadvertisementimg2.imgPath!}"/>
                </td>
                <th></th>
                <td>

                
                </td>
              </tr>           
              <tr>
                <th >预览广告图片：</th>
                <td ><img src="${base}${czjadvertisementimg2.imgPath!}" height="140px;" id="firstImg"></td>
                <th ></th>
                <td ></td>
              </tr> 
              

              

     </form>   

       <tr>
            <td colspan="4" width="100%" style="text-align: center;">

                <a class="btn btn-success  approve-btn btn-approve" href="javascript:submitVoteOrder()">&nbsp;提交&nbsp;</a>
                <span >&nbsp;</span>
                <#if czjadvertisementimg2.ext1??>
                   <#if  czjadvertisementimg2.ext1?? && czjadvertisementimg2.ext1 == "1">
                   <a class="btn btn-danger approve-btn" href="javascript:javascript:notRelease()">&nbsp;不发布&nbsp</a>
                   <#else>
                   <a class="btn btn-success  approve-btn btn-approve" href="javascript:release()">&nbsp;发布&nbsp;</a>
                   </#if>  
                </#if>    
            </td>
        </tr>



        </tbody>
    </table>

</div>

<script type="text/javascript">
   
   //不发布
  function notRelease(){
	  location.href="${base}/advertisementimg2/czjadvertisementimg2SaveExt1.do?advertisementId=${czjadvertisementimg2.advertisementId!}&ext1=0";
  }

  //发布
  function release(){
	  location.href="${base}/advertisementimg2/czjadvertisementimg2SaveExt1.do?advertisementId=${czjadvertisementimg2.advertisementId!}&ext1=1";
  }

  //提交图片
  function submitVoteOrder(){
	  
	  var imgOrder = $("#imgOrder").val();
	  
	  if(imgOrder == ""){
      	alert("图片顺序不能为空");
    	return false;
	  }	  	  
	  if(!isInteger(imgOrder)){
	      	alert("图片顺序只能是正整数");
	    	return false;
	  }	
	  if(imgOrder<=0){
	      	alert("图片顺序只能是正整数");
	    	return false;
	  }	 
	  if(isNaN(imgOrder)){
	      	alert("图片顺序只能是数字");
	    	return false;
		  }
	  

	        	
	         document.getElementById("myform").submit(); 
	  	  	  	  	  	  	 
  }
  
  
  function isInteger(obj) {
   return obj%1 === 0
  }
  isInteger(3) // true
  isInteger(3.3) // false　
     
  

  
  
</script>

</body>
</html>